﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
 
using System.Text;
using System.Windows.Forms;

namespace Demo
{
    public partial class shapes : DemoBaseUserControl
    {
        FarPoint.Win.Spread.DrawingSpace.DrawingToolbar draw;
        public shapes()
        {
            InitializeComponent();
            this.Title = "图形";
            this.Description = "Spread .NET  提供了丰富的图形类型，下面示例中展示了应用 Spread 绘画的流程图，用鼠标点击任意图形可以弹出图形工具条进行编辑。";
        }

        void ShowToolbar()
        {
            //  place this code whereever you want to instantiate the drawing toolbar
            if (!(FpSpread1.ActiveSheet == null))
            {
                draw = new FarPoint.Win.Spread.DrawingSpace.DrawingToolbar(FpSpread1, FpSpread1.ActiveSheet.DrawingContainer);
            }
            else
            {
                draw = new FarPoint.Win.Spread.DrawingSpace.DrawingToolbar(FpSpread1, null);
            }
            draw.Visible = true;
            //draw.Owner =(System.Windows.Forms.Form)(this);
            draw.Left = (this.Left
                        + (this.Width
                        - (draw.Width / 2)));
            draw.Top = (this.Top
                        + ((this.Height / 2)
                        - (draw.Height / 2)));
        }
        private void FpSpread1_ShapeActivated(object sender, EventArgs e)
        {
            ShowToolbar();
        } 

        private void FpSpread1_ShapeDeactivated_1(object sender, EventArgs e)
        {
            if (!(draw == null))
            {
                draw.Close();
                draw.Dispose();
                draw = null;
            }
        }

        private void shapes_Load_1(object sender, EventArgs e)
        {
            FpSpread1.ActiveSheet.Cells[11, 11].Text = "试试看!(点击任意图形弹出图形工具条)";
            FpSpread1.ActiveSheet.Cells[4, 2].Text = "使用 Spread 图形创建的流程图。";
            FpSpread1.ActiveSheet.Cells[4, 2].Font = new Font("微软雅黑", 10, FontStyle.Bold);
            FpSpread1.ActiveSheet.Cells[11, 11].Font = new Font("微软雅黑", 10, FontStyle.Bold);
            // Allow text to overflow
            FpSpread1.AllowCellOverflow = true;
        }



    }
}
